Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-11405] Account Management: Prevent a verified user from changing their email address #4875

Conversation

r-tome
Copy link
Contributor

@r-tome r-tome commented Oct 10, 2024

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-11405

📔 Objective

If the Account Deprovisioning feature flag is enabled and the user is managed by an organization then block the Change Email endpoints.

Block the AccountsController.PostEmail endpoint
Block the AccountsController.PostEmailToken endpoint

Clients PR: bitwarden/clients#11486

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@r-tome r-tome changed the base branch from main to ac/pm-11404/prevent-a-verified-user-from-purging-their-vault October 10, 2024 13:06
Copy link

codecov bot commented Oct 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 42.55%. Comparing base (53ad9df) to head (513e6c4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4875      +/-   ##
==========================================
+ Coverage   42.47%   42.55%   +0.08%     
==========================================
  Files        1386     1386              
  Lines       64625    64633       +8     
  Branches     5931     5933       +2     
==========================================
+ Hits        27449    27506      +57     
+ Misses      35952    35903      -49     
  Partials     1224     1224              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

github-actions bot commented Oct 10, 2024

Logo
Checkmarx One – Scan Summary & Details2e2c0e64-1c3b-40ab-b90a-ae905362cd62

New Issues

Severity Issue Source File / Package Checkmarx Insight
MEDIUM Privacy_Violation /src/Core/Auth/Services/Implementations/AuthRequestService.cs: 213 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/ProviderClientsController.cs: 29 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/ProviderClientsController.cs: 29 Attack Vector

Fixed Issues

Severity Issue Source File / Package
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationUsersController.cs: 106
MEDIUM CSRF /src/Billing/Controllers/RecoveryController.cs: 38
MEDIUM CSRF /src/Api/Vault/Controllers/CiphersController.cs: 107
MEDIUM CSRF /src/Admin/AdminConsole/Controllers/OrganizationsController.cs: 351
MEDIUM CSRF /src/Billing/Controllers/StripeController.cs: 164
MEDIUM CSRF /src/Api/AdminConsole/Public/Controllers/MembersController.cs: 95
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationUsersController.cs: 238
MEDIUM CSRF /src/Api/AdminConsole/Controllers/PoliciesController.cs: 75
MEDIUM CSRF /src/Api/AdminConsole/Controllers/PoliciesController.cs: 58
MEDIUM CSRF /src/Api/AdminConsole/Public/Controllers/PoliciesController.cs: 42
MEDIUM CSRF /src/Api/Vault/Controllers/CiphersController.cs: 107
MEDIUM CSRF /src/Api/AdminConsole/Public/Controllers/PoliciesController.cs: 62
MEDIUM CSRF /src/Admin/AdminConsole/Controllers/OrganizationsController.cs: 351
MEDIUM CSRF /src/Api/Vault/Controllers/CiphersController.cs: 690
MEDIUM Privacy_Violation /src/Core/Auth/Services/Implementations/AuthRequestService.cs: 208
LOW Log_Forging /src/Api/Vault/Controllers/CiphersController.cs: 170
LOW Log_Forging /src/Identity/Controllers/AccountsController.cs: 144
LOW Log_Forging /src/Identity/Controllers/AccountsController.cs: 76

…sManagedByAnyOrganizationAsync to not return nullable objects. Update ProfileOrganizationResponseModel.UserIsManagedByOrganization to not be nullable
…vault' into ac/pm-11405/prevent-a-verified-user-from-changing-their-email-address
@r-tome r-tome changed the title [PM-11405] Account Deprovisioning: Prevent a verified user from changing their email address [PM-11405] Account Management: Prevent a verified user from changing their email address Oct 11, 2024
Base automatically changed from ac/pm-11404/prevent-a-verified-user-from-purging-their-vault to main October 17, 2024 15:06
@r-tome r-tome marked this pull request as ready for review October 18, 2024 11:50
@r-tome r-tome requested a review from a team as a code owner October 18, 2024 11:50
@r-tome r-tome requested a review from rr-bw October 18, 2024 11:50
@rr-bw rr-bw requested review from ike-kottlowski and removed request for rr-bw October 18, 2024 16:55
Copy link
Contributor

@ike-kottlowski ike-kottlowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a non-blocking thought on integration tests.

…piApplicationFactory to be able to enable specific features for each test
@eliykat eliykat requested review from eliykat and removed request for eliykat October 23, 2024 20:59
@r-tome r-tome requested a review from eliykat October 25, 2024 10:05
Copy link
Contributor

@JaredSnider-Bitwarden JaredSnider-Bitwarden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Tests look great!

@r-tome r-tome merged commit c126fee into main Oct 28, 2024
50 checks passed
@r-tome r-tome deleted the ac/pm-11405/prevent-a-verified-user-from-changing-their-email-address branch October 28, 2024 16:12
cyprain-okeke pushed a commit that referenced this pull request Oct 30, 2024
…their email address (#4875)

* Add check for managed user before purging account

* Rename IOrganizationRepository.GetByClaimedUserDomainAsync to GetByVerifiedUserEmailDomainAsync and refactor to return a list. Remove ManagedByOrganizationId from ProfileResponseMode. Add ManagesActiveUser to ProfileOrganizationResponseModel

* Rename the property ManagesActiveUser to UserIsManagedByOrganization

* Remove whole class #nullable enable and add it to specific places

* [PM-11405] Account Deprovisioning: Prevent a verified user from changing their email address

* Remove unnecessary .ToList()

* Refactor IUserService methods GetOrganizationsManagingUserAsync and IsManagedByAnyOrganizationAsync to not return nullable objects. Update ProfileOrganizationResponseModel.UserIsManagedByOrganization to not be nullable

* Update error message when unable to purge vault for managed account

* Update error message when unable to change email for managed account

* Update expected error messages on unit tests

* Add TestFeatureService to Api.IntegrationTest.Helpers and use it on ApiApplicationFactory to be able to enable specific features for each test

* Add CreateVerifiedDomainAsync method to OrganizationTestHelpers

* Add tests to AccountsControllerTest to prevent changing email for managed accounts

* Remove setting the feature flag value in ApiApplicationFactory and set it on AccountsControllerTest

* Remove TestFeatureService class from Api.IntegrationTest.Helpers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants